package com.atstudy.headline.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 广告效果日统计表
 * @TableName ad_performance_daily
 */
@TableName(value ="ad_performance_daily")
@Data
public class AdPerformanceDaily {
    /**
     * ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 统计日期
     */
    private Date statDate;

    /**
     * 广告计划ID(为NULL表示所有计划)
     */
    private Integer campaignId;

    /**
     * 广告创意ID(为NULL表示所有创意)
     */
    private Integer creativeId;

    /**
     * 广告主ID(为NULL表示所有广告主)
     */
    private Integer advertiserId;

    /**
     * 展示次数
     */
    private Integer impressionCount;

    /**
     * 点击次数
     */
    private Integer clickCount;

    /**
     * 转化次数
     */
    private Integer conversionCount;

    /**
     * 消耗金额
     */
    private BigDecimal costAmount;

    /**
     * 点击率(%)
     */
    private BigDecimal ctr;

    /**
     * 转化率(%)
     */
    private BigDecimal cvr;

    /**
     * 平均点击成本
     */
    private BigDecimal cpc;

    /**
     * 千次展示成本
     */
    private BigDecimal cpm;

    /**
     * 平均转化成本
     */
    private BigDecimal cpa;

    /**
     * 创建时间
     */
    private Date createTime;

    // 关联字段
    //计划名称
    @TableField(exist = false)
    private String campaignName;

    //标题
    @TableField(exist = false)
    private String title;

    //公司名称
    @TableField(exist = false)
    private String companyName;

    //广告标题
    @TableField(exist = false)
    private String description;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        AdPerformanceDaily other = (AdPerformanceDaily) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getStatDate() == null ? other.getStatDate() == null : this.getStatDate().equals(other.getStatDate()))
            && (this.getCampaignId() == null ? other.getCampaignId() == null : this.getCampaignId().equals(other.getCampaignId()))
            && (this.getCreativeId() == null ? other.getCreativeId() == null : this.getCreativeId().equals(other.getCreativeId()))
            && (this.getAdvertiserId() == null ? other.getAdvertiserId() == null : this.getAdvertiserId().equals(other.getAdvertiserId()))
            && (this.getImpressionCount() == null ? other.getImpressionCount() == null : this.getImpressionCount().equals(other.getImpressionCount()))
            && (this.getClickCount() == null ? other.getClickCount() == null : this.getClickCount().equals(other.getClickCount()))
            && (this.getConversionCount() == null ? other.getConversionCount() == null : this.getConversionCount().equals(other.getConversionCount()))
            && (this.getCostAmount() == null ? other.getCostAmount() == null : this.getCostAmount().equals(other.getCostAmount()))
            && (this.getCtr() == null ? other.getCtr() == null : this.getCtr().equals(other.getCtr()))
            && (this.getCvr() == null ? other.getCvr() == null : this.getCvr().equals(other.getCvr()))
            && (this.getCpc() == null ? other.getCpc() == null : this.getCpc().equals(other.getCpc()))
            && (this.getCpm() == null ? other.getCpm() == null : this.getCpm().equals(other.getCpm()))
            && (this.getCpa() == null ? other.getCpa() == null : this.getCpa().equals(other.getCpa()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getStatDate() == null) ? 0 : getStatDate().hashCode());
        result = prime * result + ((getCampaignId() == null) ? 0 : getCampaignId().hashCode());
        result = prime * result + ((getCreativeId() == null) ? 0 : getCreativeId().hashCode());
        result = prime * result + ((getAdvertiserId() == null) ? 0 : getAdvertiserId().hashCode());
        result = prime * result + ((getImpressionCount() == null) ? 0 : getImpressionCount().hashCode());
        result = prime * result + ((getClickCount() == null) ? 0 : getClickCount().hashCode());
        result = prime * result + ((getConversionCount() == null) ? 0 : getConversionCount().hashCode());
        result = prime * result + ((getCostAmount() == null) ? 0 : getCostAmount().hashCode());
        result = prime * result + ((getCtr() == null) ? 0 : getCtr().hashCode());
        result = prime * result + ((getCvr() == null) ? 0 : getCvr().hashCode());
        result = prime * result + ((getCpc() == null) ? 0 : getCpc().hashCode());
        result = prime * result + ((getCpm() == null) ? 0 : getCpm().hashCode());
        result = prime * result + ((getCpa() == null) ? 0 : getCpa().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", statDate=").append(statDate);
        sb.append(", campaignId=").append(campaignId);
        sb.append(", creativeId=").append(creativeId);
        sb.append(", advertiserId=").append(advertiserId);
        sb.append(", impressionCount=").append(impressionCount);
        sb.append(", clickCount=").append(clickCount);
        sb.append(", conversionCount=").append(conversionCount);
        sb.append(", costAmount=").append(costAmount);
        sb.append(", ctr=").append(ctr);
        sb.append(", cvr=").append(cvr);
        sb.append(", cpc=").append(cpc);
        sb.append(", cpm=").append(cpm);
        sb.append(", cpa=").append(cpa);
        sb.append(", createTime=").append(createTime);
        sb.append("]");
        return sb.toString();
    }
}
